import {expect} from 'chai';
import {ExploitationOfVenus} from '../../../src/server/cards/underworld/ExploitationOfVenus';
import {testGame} from '../../TestGame';
import {cast} from '../../TestingUtils';

describe('ExploitationOfVenus', () => {
  const effectRuns = [
    {player: 0, steps: 1, expected: 2},
    {player: 0, steps: 2, expected: 4},
    {player: 0, steps: -1, expected: 0},
    {player: 1, steps: 1, expected: 2},
    {player: 1, steps: 2, expected: 4},
    {player: 1, steps: -1, expected: 0},
  ] as const;
  for (const run of effectRuns) {
    it('effect ' + JSON.stringify(run), () => {
      const card = new ExploitationOfVenus();
      const [game, player] = testGame(2, {underworldExpansion: true, venusNextExtension: true});

      cast(card.play(player), undefined);

      const activePlayer = game.players[run.player];
      game.increaseVenusScaleLevel(activePlayer, run.steps);
      expect(activePlayer.megaCredits).eq(run.expected);
    });
  }

  it('can act', () => {
    const card = new ExploitationOfVenus();
    const [game, player] = testGame(2, {underworldExpansion: true, venusNextExtension: true});
    player.playedCards.push(card);
    cast(card.play(player), undefined);

    expect(card.canAct(player)).is.false;

    player.underworldData.corruption = 1;

    expect(card.canAct(player)).is.true;

    cast(card.action(player), undefined);

    expect(game.getVenusScaleLevel()).eq(2);
    expect(player.megaCredits).eq(2);
    expect(player.terraformRating).eq(21);
  });
});
